/**
 * @file   ExecuteMethodRequestPacket.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2014-04-24
 * @brief  DON packet object: Execute Method Request
 *
 * Copyright 2014  Djuro Drljaca (djurodrljaca@gmail.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DON_CORE_PACKET_EXECUTEMETHODREQUESTPACKET_H
#define DON_CORE_PACKET_EXECUTEMETHODREQUESTPACKET_H

#include <DON/Core/Packet/AbstractPacket.h>
#include <DON/Core/DataType/AbstractDataType.h>

namespace DON
{
namespace Core
{
namespace Packet
{

/**
 * @brief The ExecuteMethodRequestPacket class
 */
class LIBDONQT4CORESHARED_EXPORT ExecuteMethodRequestPacket : public AbstractPacket
{
public:
    /**
     * @brief Constructor
     */
    ExecuteMethodRequestPacket();

    /**
     * @brief Constructor
     * @param source Packet's Source address
     * @param destination Packet's Destination address
     * @param sequence Sequence number
     * @param methodId Method ID
     */
    ExecuteMethodRequestPacket(const quint16 source,
                               const quint16 destination,
                               const quint16 sequence,
                               const quint16 methodId);

    /**
     * @brief Copy constructor
     * @param other Object to be copied
     */
    ExecuteMethodRequestPacket(const ExecuteMethodRequestPacket &other);

    /**
     * @brief Destructor
     */
    ~ExecuteMethodRequestPacket();

    /**
     * @brief Assignment operator
     * @param other Object to be copied
     * @return This object
     */
    ExecuteMethodRequestPacket & operator=(const ExecuteMethodRequestPacket &other);

    /**
     * @brief Checks if packet is valid
     * @retval true Packet is valid
     * @retval false Packet is not valid
     */
    bool isValid() const;

    /**
     * @brief Get method ID
     * @return Method ID
     */
    quint16 getMethodId() const;

    /**
     * @brief Set method ID
     * @param methodId New method ID
     */
    void setMethodId(const quint16 methodId);

    /**
     * @brief Get method argument value count
     * @return Method argument value count
     */
    int getMethodArgumentValueCount() const;

    /**
     * @brief Get method argument value
     * @param index Index of the argument
     * @return Method argument value at the selected index
     * @retval NULL Invalid index
     */
    const DataType::AbstractDataType * getMethodArgumentValue(const int index) const;

    /**
     * @brief Set method argument value at the selected index
     * @param argumentValue Method's argument value
     * @param index Index of the argument
     * @retval true Success
     * @retval false Error
     */
    bool setMethodArgumentValue(const DataType::AbstractDataType &argumentValue, const int index);

    /**
     * @brief Add method argument value
     * @param argumentValue New argument value
     * @retval true Success
     * @retval false Error
     *
     * @note Method argument value is added to the end of the argument value list.
     */
    bool addMethodArgumentValue(const DataType::AbstractDataType &argumentValue);

    /**
     * @brief Remove method argument value
     * @param index Index of the argument
     * @retval true Success
     * @retval false Error
     */
    bool removeMethodArgumentValue(const int index) const;

    /**
     * @brief Remove all method argument values
     */
    void removeAllMethodArgumentValues();

    /**
     * @brief Get maximum number of method argument values
     * @return Maximum number of method argument values
     */
    static int getMaxMethodArgumentValueCount();

private:
    /**
     * @brief Get the packet's payload data items
     * @param[out] ok Error status output (true --> success, false --> error)
     * @return List of payload data items
     */
    QList<QByteArray> getPayloadDataItems(bool *ok = NULL) const;

    class Private;
    Private * const d;
};

}
}
}

#endif // DON_CORE_PACKET_EXECUTEMETHODREQUESTPACKET_H
